<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.io.BufferedReader,java.io.InputStreamReader,java.net.URL,java.net.URLConnection"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
  %>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="FlappySeekerTeam" />
<meta name="keywords" content="高考,选专业,评测,性格,天赋,爱好" />
<meta name="description" content="FlappySeekerTeam重拳打造的一款适应高考同学选择专业的辅助类应用，该应用的原理是通过每个人的个性、天赋来判断自身的特点以匹配什么样的专业和工作适合自已，同时站在3年或4年的就业线上反向建议专业选择，以帮助考高同学们走出选择盲区。中国软件行业协会、IBM、微软人资联合推荐" />

<link rel="shortcut icon" href="">
<link rel="stylesheet" href="../../css/bootstrap.min.css">
 <!--[if lt IE 9]>
        <script src="../../js/html5shiv.min.js"></script>
		<script src="../../js/respond.min.js"></script>
<![endif]-->
<script>var basepath = '<%=basePath%>';
</script>
<link rel="stylesheet" href="../../css/seeker.css">
<title>高考专业填报测试平台</title>
</head>
<body>
<jsp:include page="../common/header.jsp" />
 <div class="container theme-showcase" role="main">
 <div class="container col-sm-10 col-md-10 col-lg-10 col-sm-offset-1 col-md-offset-1 col-lg-offset-1">
 <div class="page-header"><h3><span class="glyphicon glyphicon-user"></span> 专业正式版入口</h3></div>

<form id="loginform" role="form" class="form-horizontal"  autocomplete="off">
 <div class="form-group">
  	<label for="username" class="col-sm-4 control-label"><strong class="text-danger">*</strong>真实姓名</label>
   <div class="col-sm-3">
     <input type="text" class="form-control" id="username" name="username" placeholder="请输入真实姓名">
   </div>
 </div>
 
 <div class="form-group">
  	<label for="usertel" class="col-sm-4 control-label"><strong class="text-danger">*</strong>手机号码</label>
   <div class="col-sm-3">
     <input type="tel" class="form-control" id="usertel" name="usertel"  onkeyup="onlyNum(this);" placeholder="请输入手机号码" maxlength="11">
   </div>
 </div>
  <div class="form-group">
  	<label for="usertel" class="col-sm-4 control-label"><strong class="text-danger">*</strong>验证码</label>
   <div class="form-inline col-sm-4">
     <input type="tel" class="form-control" id="code" name="vsmscode"  placeholder="请输入手机验证码" maxlength="6">
     <button id="getcode" type="button" data-billing="s" data-loading-text="发送中..."  class="btn btn-default btn-sm">发送验证码</button>
   </div>
 </div>
  <div class="form-group">
  	<label for="serial" class="col-sm-4 control-label"><strong class="text-danger">*</strong>序列号</label>
   <div class="form-inline col-sm-4">
     <input type="text" class="form-control" id="serial" name="verificode"  placeholder="请输入购买的序列号">
     <button id = "btnverificode" type="button" class="btn btn-default btn-sm">购买序列号</button>
   </div>
 </div>
<div class="form-group">
 	<div class="col-sm-offset-4 col-sm-5">
 		<button id="start" type="button" data-loading-text="验证信息..." class="btn btn-primary">开始测试</button>
		 </div>
</div>
</form>
<a id="urlto" href="../alipay/alipayto.jsp" rel="external" target="_blank"></a> 
</div>
</div>
<jsp:include page="../common/footer.jsp" />
 
<script src="../../js/jquery.min.js"></script>
<script src="../../js/bootstrap.min.js"></script>
<script src="../../js/jquery.form.js"></script>
<script src="../../js/common.js"></script>
<script src="../../layer/layer.min.js"></script>
<script>

$("#code").blur(function(){
	if(checkName($('#username')) == false) return false;
	if(checkPhone($('#usertel')) == false) return false;
	var cvalue = $("#code").val();
	if($.trim($('#code').val()).length == 0) {
		errorMsg($('#loginform'), '请输入手机验证码。', 'form-group');
		$('.alert').addClass('col-sm-6 col-sm-offset-3');
		return false;
	}else{
		$("#getcode").text('验证中...');
		$.ajax({
            type: "POST",
            url: "../../sms/smsverific.action",
            data: {username:$.trim($("#username").val()), usertel:$.trim($("#usertel").val()),vsmscode:$.trim($('#code').val())},
            success: function(data){
            	var res =  eval(data)[0];
            	if(res.smsverific == 'true') {
            		$("#getcode").text('验证通过');
            		$("#getcode").css("color","green");
            		$("#getcode").addClass('disabled').attr('disabled', 'disabled');
            	}else{
            		errorMsg($('#loginform'), '手机验证码错误，请确认后重新输入，或重新发送验证码。', 'form-group');
            		
                	$("#getcode").text('发送验证码');
            		$("#getcode").css("color","#000");
            		$("#getcode").removeClass('disabled').removeAttr('disabled');
            	}
            	
            },
            error:function(data){
            	
            }
        });
		return true;
	}
});

var options = {
	  url: basepath + '/contoller/alipayto.action',
	  type: 'POST',
      beforeSubmit:showRequest,
      success: function(data, status) {
  		var res =  eval(data)[0];
  		if(res.suc == 0) {
  			showError(res.msg);
  			return;
  		}else if(res.suc == 1) {
	  		$.layer({
	  	        type: 2,
	  	        title: '购买序列号,支付后点[X]可继续操作',
	  	        shadeClose: true, //开启点击遮罩关闭层
	  	        area : [$(window).width()-16 , $(window).height()-30],
	  	        offset : ['5px', ''],
	  	     	border: [0],
	  	        iframe: {src: '../alipay/alipayto.jsp'}
	  	    });
  			return;
  		}  
      	function showError(msg) {
      		$('#start').button('reset');
      		errorMsg($('#loginform'), msg, 'form-group');
      		$('.alert').addClass('col-sm-6 col-sm-offset-3');
      	}
  	},
  	error: function(xhr, status) {
  		$('#start').button('reset');
  		errorMsg($('#loginform'), '网络错误。('+status+')', 'form-group');
  		$('.alert').addClass('col-sm-6 col-sm-offset-3');
      },
      timeout:3000
  };
$('#btnverificode').click(function() { 
    $('#loginform').ajaxSubmit(options); 
    return false; 
});

function showRequest(formData, jqForm, options) {
	if(checkName($('#username')) == false) return false;
	if(checkPhone($('#usertel')) == false) return false;
	if($.trim($('#code').val()).length == 0) {
		errorMsg($('#loginform'), '请输入手机验证码。', 'form-group');
		$('.alert').addClass('col-sm-6 col-sm-offset-3');
		return false;
	}
	return true;
}


$('#start').click(function() { 
	var options = {
		url: basepath + '/cmd/cmdurl2sf.action',
		type: 'POST',
		beforeSubmit: function(arr) {
			if(checkName($('#username')) == false) return false;
			if(checkPhone($('#usertel')) == false) return false;
			if($.trim($('#code').val()).length == 0) {
				errorMsg($('#loginform'), '请输入手机验证码。', 'form-group');
				$('.alert').addClass('col-sm-6 col-sm-offset-3');
				return false;
			}
			if($.trim($('#serial').val()).length == 0) {
				errorMsg($('#loginform'), '请输入序列号。', 'form-group');
				$('.alert').addClass('col-sm-6 col-sm-offset-3');
				return false;
			}
			$('#start').button('loading');
			return true;
		},
		success: function(data, status) {
			var res =  eval(data)[0];
			if(res.suc == 0) {
				showError(res.msg);
				return;
			} else if(res.suc == 1){
				window.location.href = "stage_1.jsp"
				return;
			} else if(res.suc == 2) {
				window.location.href = "stage_2.jsp"
				return;
			} else {
				showError('发生了错误，请稍后再试。('+status+')');
	    		return;
			}
	    	function showError(msg) {
	    		$('#start').button('reset');
	    		errorMsg($('#loginform'), msg, 'form-group');
	    		$('.alert').addClass('col-sm-6 col-sm-offset-3');
	    	}
		},
		error: function(xhr, status) {
			$('#start').button('reset');
			errorMsg($('#loginform'), '网络错误。('+status+')', 'form-group');
			$('.alert').addClass('col-sm-6 col-sm-offset-3');
	    },
	    timeout:3000
	  };
	$('#loginform').ajaxSubmit(options); 
    return false; 
});


</script>
</body>
</html>